using Microsoft.Win32;

namespace CriticalSystems.Instrumentation
{
    internal class RegistryKeyWrapper : IRegistryKey
    {
        private readonly RegistryKey registryKey;

        public RegistryKeyWrapper(RegistryKey registryKey)
        {
            this.registryKey = registryKey;
        }

        #region IRegistryKey Members
        public IRegistryKey CreateSubKey(string subkey)
        {
            return new RegistryKeyWrapper(registryKey.CreateSubKey(subkey));
        }

        public void DeleteSubKey(string subkey)
        {
            registryKey.DeleteSubKey(subkey);
        }

        public void DeleteSubKeyTree(string subkey)
        {
            registryKey.DeleteSubKeyTree(subkey);
        }

        public void DeleteValue(string name)
        {
            registryKey.DeleteValue(name);
        }

        public IRegistryKey OpenSubKey(string name, bool writable)
        {
            var regKey = registryKey.OpenSubKey(name, writable);
            return new RegistryKeyWrapper(regKey);
        }

        public object GetValue(string name)
        {
            return registryKey.GetValue(name);
        }

        public void SetValue(string name, object value)
        {
            registryKey.SetValue(name, value);
        }
        #endregion
    }
}